home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************\
-
- File: ls shift.c
-
- Purpose: This module handles shifting/rotating the board.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program in a file named "GNU General Public License".
- If not, write to the Free Software Foundation, 675 Mass Ave,
- Cambridge, MA 02139, USA.
-
- \**********************************************************************/
-
- #include "ls shift.h"
- #include "program globals.h"
-
- void ShiftLeftDispatch(ExtendedWindowDataHandle theData)
- {
- short tempValue;
- short theRow, theColumn;
- short moveIter;
-
- for (theRow=0; theRow<gNumRows; theRow++)
- {
- tempValue=Board[theRow][0];
-
- for (theColumn=0; theColumn<gNumColumns-1; theColumn++)
- {
- Board[theRow][theColumn]=Board[theRow][theColumn+1];
- }
-
- Board[theRow][gNumColumns-1]=tempValue;
- }
-
- for (moveIter=0; moveIter<gNumMoves; moveIter++)
- {
- gMoves[moveIter].h--;
- if (gMoves[moveIter].h<0)
- gMoves[moveIter].h=gNumRows-1;
- }
-
- gCurrentColumn--;
- if (gCurrentColumn<0)
- gCurrentColumn=gNumColumns-1;
-
- (**theData).offscreenNeedsUpdate=TRUE;
- UpdateTheWindow(theData);
- }
-
- void ShiftRightDispatch(ExtendedWindowDataHandle theData)
- {
- short tempValue;
- short theRow, theColumn;
- short moveIter;
-
- for (theRow=0; theRow<gNumRows; theRow++)
- {
- tempValue=Board[theRow][gNumColumns-1];
-
- for (theColumn=gNumColumns-1; theColumn>0; theColumn--)
- {
- Board[theRow][theColumn]=Board[theRow][theColumn-1];
- }
-
- Board[theRow][0]=tempValue;
- }
-
- for (moveIter=0; moveIter<gNumMoves; moveIter++)
- {
- gMoves[moveIter].h++;
- if (gMoves[moveIter].h==gNumRows)
- gMoves[moveIter].h=0;
- }
-
- gCurrentColumn++;
- if (gCurrentColumn==gNumColumns)
- gCurrentColumn=0;
-
- (**theData).offscreenNeedsUpdate=TRUE;
- UpdateTheWindow(theData);
- }
-
- void ShiftUpDispatch(ExtendedWindowDataHandle theData)
- {
- short tempValue;
- short theRow, theColumn;
- short moveIter;
-
- for (theColumn=0; theColumn<gNumColumns; theColumn++)
- {
- tempValue=Board[0][theColumn];
-
- for (theRow=0; theRow<gNumRows-1; theRow++)
- {
- Board[theRow][theColumn]=Board[theRow+1][theColumn];
- }
-
- Board[gNumColumns-1][theColumn]=tempValue;
- }
-
- for (moveIter=0; moveIter<gNumMoves; moveIter++)
- {
- gMoves[moveIter].v--;
- if (gMoves[moveIter].v<0)
- gMoves[moveIter].v=gNumColumns-1;
- }
-
- gCurrentRow--;
- if (gCurrentRow<0)
- gCurrentRow=gNumRows-1;
-
- (**theData).offscreenNeedsUpdate=TRUE;
- UpdateTheWindow(theData);
- }
-
- void ShiftDownDispatch(ExtendedWindowDataHandle theData)
- {
- short tempValue;
- short theRow, theColumn;
- short moveIter;
-
- for (theColumn=0; theColumn<gNumColumns; theColumn++)
- {
- tempValue=Board[gNumRows-1][theColumn];
-
- for (theRow=gNumRows-1; theRow>0; theRow--)
- {
- Board[theRow][theColumn]=Board[theRow-1][theColumn];
- }
-
- Board[0][theColumn]=tempValue;
- }
-
- for (moveIter=0; moveIter<gNumMoves; moveIter++)
- {
- gMoves[moveIter].v++;
- if (gMoves[moveIter].v==gNumColumns)
- gMoves[moveIter].v=0;
- }
-
- gCurrentRow++;
- if (gCurrentRow==gNumRows)
- gCurrentRow=0;
-
- (**theData).offscreenNeedsUpdate=TRUE;
- UpdateTheWindow(theData);
- }
-
- void RotateCCWDispatch(ExtendedWindowDataHandle theData)
- {
-
- }
-
- void RotateCWDispatch(ExtendedWindowDataHandle theData)
- {
-
- }
-